import { _decorator, Component, Node, director, Input, SpriteFrame, UITransform, Sprite } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('GameStopRestart')
export class GameStopRestart extends Component {
    
    /**
     * 游戏状态 0 暂停 1 正在运行
     */
    status: number = 1;

    @property(SpriteFrame)
    pauseImg: SpriteFrame;

    @property(SpriteFrame)
    startImg: SpriteFrame;
    
    start() {
        this.node.on(Input.EventType.TOUCH_END, this.gameControl, this)
    }

    update(deltaTime: number) {
        
    }

    // 游戏控制
    gameControl() {
        if(this.status == 1) {
            // 暂停
            this.status = 0
            this.getComponent(Sprite).spriteFrame = this.startImg
            director.pause()
            
        }else {
            this.status = 1
            this.getComponent(Sprite).spriteFrame = this.pauseImg
            director.resume()
        }
    }



}


